package com.framework.common.Enums;

/**
 * 用户类型枚举
 */
public enum UserTypeEnum {

	DEFAULT("默认角色", "DEFAULT", 0),
	TOURIST_ORG("机构", "ROLE_ORG", 2),
	GUIDE("领队", "ROLE_GUIDE", 1),
	FLEET("车队", "ROLE_FLEET", 6),
	DRIVER("司机", "ROLE_DRIVER", 7),
	TOURIST("游客", "ROLE_TOURIST", 5);

    private final String name;

    private final String code;

    private final Integer value;

    private UserTypeEnum(String name, String code, Integer value) {
        this.name = name;
        this.code = code;
        this.value = value;
    }

    public String getName() {
        return name;
    }

    public String getCode() {
		return code;
	}

	public Integer getValue() {
        return value;
    }
	
	public static Integer getValue(String code) {
		UserTypeEnum[] values = UserTypeEnum.values();
    	for (UserTypeEnum e : values) {
    		if (e.getCode().equals(code)) {
    			return e.getValue();
    		}
    	}
    	return null;
	}
	
	public static String getCode(Integer value) {
    	for (UserTypeEnum e : UserTypeEnum.values()) {
    		if (e.getValue().equals(value)) {
    			return e.getCode();
    		}
    	}
    	return null;
	}
	
	public static String getName(Integer value) {
    	for (UserTypeEnum e : UserTypeEnum.values()) {
    		if (e.getValue().equals(value)) {
    			return e.getName();
    		}
    	}
    	return null;
	}
}
